/*************************************************************************
	> File Name: P1102A-B数对.cpp
	> Author: 
	> Mail: 
	> Created Time: 
 ************************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    map<long long, long long> m;
    long long n, c;
    cin >> n >> c;
    vector<long long> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        m[arr[i]]++;
    }
    long long cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt += m[arr[i] + c];
    }
    cout << cnt << endl;
    return 0;
}
